package com.teng.smartdrawer.utils;

import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

/**
 * 计算Listview footer高度的工具类
 * 
 * @author hackest
 *
 */

public class MetricsUtil extends Activity {
	public static double CURRENT_DENSITY = 0.0D;
	public static double CURRENT_SCREEN_HEIGHT = 0.0D;
	public static double CURRENT_SCREEN_WIDTH = 0.0D;
	public static double RATIO_DENSITY = 0.0D;
	public static double RATIO_HEIGHT = 0.0D;
	public static double RATIO_WIDTH = 0.0D;
	public static final double STANDARD_DENSITY = 160.0D;
	public static double STANDARD_SCREEN_HEIGHT;
	public static double STANDARD_SCREEN_WIDTH = 1080.0D;

	static {
		STANDARD_SCREEN_HEIGHT = 1920.0D;
		CURRENT_SCREEN_WIDTH = 1080.0D;
		CURRENT_SCREEN_HEIGHT = 1920.0D;
		CURRENT_DENSITY = 160.0D;
		RATIO_WIDTH = CURRENT_SCREEN_WIDTH / STANDARD_SCREEN_WIDTH;
		RATIO_HEIGHT = CURRENT_SCREEN_HEIGHT / STANDARD_SCREEN_HEIGHT;
		RATIO_DENSITY = CURRENT_DENSITY / 160.0D;
	}

	public static float getCurrentHeightSize(int paramInt) {
		return (float) (paramInt * RATIO_HEIGHT * RATIO_DENSITY);
	}

	public static float getCurrentTextSize(int paramInt) {
		return (float) (paramInt * RATIO_WIDTH * RATIO_DENSITY);
	}

	public static float getCurrentWidthSize(int paramInt) {
		return (float) (paramInt * RATIO_WIDTH * RATIO_DENSITY);
	}

	public static void getCurrentWindowMetrics(Context context) {
		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		DisplayMetrics localDisplayMetrics = new DisplayMetrics();
		// ((Activity)
		// context).getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
		wm.getDefaultDisplay().getMetrics(localDisplayMetrics);
		CURRENT_SCREEN_WIDTH = localDisplayMetrics.widthPixels;
		CURRENT_SCREEN_HEIGHT = localDisplayMetrics.heightPixels;
		CURRENT_DENSITY = localDisplayMetrics.densityDpi;
		RATIO_WIDTH = CURRENT_SCREEN_WIDTH / STANDARD_SCREEN_WIDTH;
		RATIO_HEIGHT = CURRENT_SCREEN_HEIGHT / STANDARD_SCREEN_HEIGHT;
		RATIO_DENSITY = 160.0D / CURRENT_DENSITY;
	}

}
